package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.RightsMapper;
import com.jt.pojo.Rights;
import com.jt.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RightsServiceImpl implements RightsService{


    @Autowired
    private RightsMapper rightsMapper;


   @Override
    public List getRightsList() {
        //1查询一级的权限信息
        QueryWrapper<Rights> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<Rights> onelist=rightsMapper.selectList(queryWrapper);
        //查询二级的下边的list集合
        for (Rights rights: onelist){
            queryWrapper.clear();//清空条件。在重新赋值
            queryWrapper.eq("parent_id", rights.getId());

        List<Rights> children=rightsMapper.selectList(queryWrapper);
        rights.setChildren(children);
        }


      return onelist;

    }
}
